<template>
    <div>
        <home-header :city="city"></home-header>
        <home-swiper :list="list"></home-swiper>
        <home-icons :iconlist="iconlist"></home-icons>
        <home-recommend :recommendlist="recommendlist"></home-recommend>
        <home-weekend :weekendlist="weekendlist"></home-weekend>
    </div>
</template>
<script>
import HomeHeader from './components/header.vue'
import HomeSwiper from './components/swiper.vue' 
import HomeIcons from './components/icons.vue'
import HomeRecommend from './components/recommend.vue'
import HomeWeekend from './components/weekend.vue'
import axios from 'axios'
export default{
    name: 'Home',
    components: {
        HomeHeader: HomeHeader,
        HomeSwiper,
        HomeIcons,
        HomeRecommend,
        HomeWeekend
    },
    data (){
        return {
            city: '',
            list: [],
            iconlist: [],
            weekendlist: [],
            recommendlist: []
        }
    },
    methods: {
        getHomeInfo (){
            axios.get('/api/index.json').then(this.getHomeInfoSucc)
        },
        getHomeInfoSucc (res){
            res = res.data
            //console.log(res.data.city)
            if(res.ret && res.data){
                const data = res.data
                this.city = data.city
                this.list = data.swiperlist
                this.iconlist = data.iconlist
                this.weekendlist = data.weekendlist
                this.recommendlist = data.recommendlist
            }
        }
    },
    mounted() {
        this.getHomeInfo()
    }
}        
</script>
<style>

</style>
